<?php
/*
Template Name: Posts
*/
?>
<?php get_header(); ?>
<?php get_sidebar(); ?>
        
<div class="container">
	
    <!--All Content Start-->
    <div class="content-wrapper">

        <!--Page Title-->
        <div class="page-title">
        	<div class="page-title-detail">
            	<h1>Blog</h1>
                <p class="sub-title">Nonumy eirmod tempor invidunt labore</p>
            </div>
            <nav class="page-navigation">
            	<ul>
                	<li><a href="index.html">home</a></li>
                    <li>blog</li>
                </ul>
            </nav>
        </div>
        <!--End-->
        
        <!--Body Content Start-->
        <section class="blog-wrapper">
        	<div class="blog-vertical">
                <ul class="blog-list blog-list-style2">
                    <?php
                        $sliderCatID = get_theme_mod('home_setting_slider');
                        $testimonialCatID = get_theme_mod('home_setting_testimonial');
                        $portfolioCatID = get_theme_mod('home_setting_portfolio');
                        
                        $args = array('category__not_in' => array($sliderCatID, $testimonialCatID, $portfolioCatID));
                                        
                        $posts = new WP_Query($args);
                    ?>
                    <?php if($posts->have_posts()): while($posts->have_posts()): $posts->the_post(); ?>
                    <?php global $post; ?>
                    <!--Blog List 1-->
                    <li>
                        <?php
                            $thumbnail = get_post_meta($post->ID, 'thumbnail', true);
                            
                            if(!empty($thumbnail)):
                        ?>
                        <figure>
                            <a href="<?php the_permalink(); ?>">
                                <!--<div class="thumbnail-hover"></div>-->
                                <img src="<?php echo $thumbnail; ?>" alt="blog list" />
                            </a>
                        </figure>
                        <?php endif; ?>
                        <div class="blog-list-detail">
                            <div class="blog-header">
                                <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                                <a href="<?php comments_link(); ?>">
                                    <div class="comment-status">
                                        <div class="comment-count"><?php comments_number("0", "1", "%"); ?></div>
                                    </div>
                                </a>
                            </div>
                            <div class="clearfix"></div>
                            <p>
                                <?php echo the_content(""); ?>
                            </p>
                            <div class="blog-list-bottom">
                                <nav class="blog-meta">
                                    <span><i class="fa fa-clock-o"></i><a href="#"><?php the_date("d-m-Y"); ?></a></span>
                                    <span><i class="fa fa-list-ul"></i><a href="#"><?php the_category(', '); ?></a></span>
                                    <span class="last-meta"><i class="fa fa-user"></i><a href="#"><?php the_author(); ?></a></span>
                                </nav>
                                <button class="dark-button" onClick="location.href='<?php the_permalink(); ?>'">Read More</button>
                            </div>
                        </div>
                    </li>
                    <!--End-->
                    <?php endwhile; ?>
                    <?php else: ?>
                    <p>Sorry, There are no posts to display!</p>
                    <?php endif; wp_reset_postdata(); ?>
                </ul>
                
                <!--Next page Start-->
                <nav class="page-count">
                    <ul>
                        <?php previous_posts_link('<li onClick="location.href=\'\'"><i class="fa fa-angle-left"></i></li>'); ?>
                        <?php 
                            $paged = ($paged > 0)? $paged : 1;
                            $total_page = ($wp_query->max_num_pages > 2)? 2 : $wp_query->max_num_pages; 
                            
                        ?>
                        <?php for($i = $page; $i <= $total_page; $i ++): ?>
                        <li <?php if($paged == $i) echo 'class="page-active"'; else echo 'onClick="location.href=\'' . get_pagenum_link($i) . '\'"' ?>><?php echo $i; ?></li>
                        <?php endfor; ?>
                        <?php next_posts_link('<li onClick="location.href=\'\'"><i class="fa fa-angle-right"></i></li>'); ?>
                    </ul>
                </nav>
                <!--Next page End-->
            
            </div>
            
            <?php get_sidebar('left'); ?>
            
        </section>
        <!--Body Content End-->
        
    </div>
    <!--All Content End-->
    
    <?php get_footer(); ?>
